<!DOCTYPE html>
<html>
<head>
  <script src="../../processing.js"></script>
  <script src="staticlib.js"></script>
  <script src="instancelib.js"></script>
  <link rel="stylesheet" href="../style.css"/></head>
<body><h1><a href="http://processingjs.org/">Processing.js</a></h1>
<h2>processing.js libraries</h2>

<p>Static and Instance Libraries</p>

<p>
<script id="script1" type="application/processing">
ComplexNumber res;

void setup()
{
  // complex type is declared in the static library
  ComplexNumber n1 = new ComplexNumber(2);
  ComplexNumber n2 = new ComplexNumber(0, 1);
  ComplexNumber n3 = new ComplexNumber(0, 1);
  res = n1.add(n2.mul(n3)); // 2 + (1i * i1) = 1

  noLoop();
}

void draw() {
  background(0);

  // printing the complex number calculation result
  text(res, 10, 10);

  // instance properties (from the instance library)
  text(clientWidth + " x " + clientHeight, 10, 50);
}

// event from the instance library
void windowResized() {
  redraw();
}

</script><canvas></canvas>

<div style="height:0px;width:0px;overflow:hidden;"></div>

<pre id="code1"></pre>
<script>
document.getElementById("code1").textContent = document.getElementById("script1").text;
</script>
</body>
</html>
